package cn.edu.hunau.oop.day02;

/**
 * @author hb
 * @date 2025-08-05 10:15:08
 */
public class Rectangle {

    Point location;
    int width;
    int height;

    public Rectangle() {
    }

    public Rectangle(Point location, int width, int height) {
        this.location = location;
        this.width = width;
        this.height = height;
    }

    public Rectangle(int x, int y, int width, int height) {
         this(new Point(x,y),width,height);
    }

    public double area(){
        return this.height*this.width;
    }

    public boolean container(Point p){
        return p.x>=this.location.x && p.x<=this.location.x+this.width && p.y>=this.location.y && p.y<=this.location.y+this.height;
    }

    public boolean container(int x,int y){
        return this.container(new Point(x,y));
    }
 }
